(function() {
    let t = {}
    t.queryAll = document.querySelectorAll.bind(document)
    t.reg = /^[0-9]+.?[0-9]*$/;
    t.add0 = (m) => { return m < 10 ? '0' + m : m }
    t.timer=null;
    t.gshDate = function(time) {
        var dateEnd = new Date(time)
        let Eyue = (dateEnd.getMonth() + 1) < 10 ? '0' + (dateEnd.getMonth() + 1) : (dateEnd.getMonth() + 1)
        let Eri = dateEnd.getDate() < 10 ? '0' + dateEnd.getDate() : dateEnd.getDate()
        let Eshi = dateEnd.getHours() < 10 ? '0' + dateEnd.getHours() : dateEnd.getHours()
        let Efen = dateEnd.getMinutes() < 10 ? '0' + dateEnd.getMinutes() : dateEnd.getMinutes()
        let Emiao = dateEnd.getSeconds() < 10 ? '0' + dateEnd.getSeconds() : dateEnd.getSeconds()
        let Time = dateEnd.getFullYear() + '-' + Eyue + '-' + Eri + ' ' + Eshi + ':' + Efen + ':' + Emiao
        return Time
    }

    t.getDate = (day, flag) => {
        var time = new Date()
        var y = time.getFullYear()
        var m = time.getMonth() + 1
        var d = time.getDate()
        var dayTime = new Date(y, m - 1, 0)
        if (day && d < day) {
            d = dayTime + d - day
            m = m - 1
        } else {
            day ? d = d - day : ''
        }
        return !flag ? y + '-' + t.add0(m) + '-' + t.add0(d) + ' 00:00:00' : y + '-' + t.add0(m) + '-' + t.add0(d) + ' 23:59:59'
    }
    t.isNumber = (number) => {
      return t.reg.test(number)
    }
    window.t = t
})()

export default t
